﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO;

namespace WpfCommander
{    
    public class FileView : View
    {
        FileSystemInfo[] list;
        string directory;


        public FileView()
        {
            this.Directory = @"C:\";
        }


        public string Directory 
        { 
            get { return directory; }
            set 
            { 
                directory = value;
                ChangeDirectory(directory);
            } 
        }


        protected override void RetriveItem(ViewItem control, int realIndex)
        {
            base.RetriveItem(control, realIndex);

            control.Text = list[realIndex].Name;
        }


        private void ChangeDirectory(string directory)
        {
            DirectoryInfo fi = new DirectoryInfo(directory);
            list = fi.GetFileSystemInfos();
            this.VirtualListSize = list.Length;

            UpdateBricks();
        }
    }
}
